package com.zzyl.serve.controller.member;

import java.util.List;

import com.zzyl.common.core.domain.R;
import com.zzyl.serve.dto.DeviceDataPageReqDto;
import com.zzyl.serve.dto.QueryDeviceDataDto;
import com.zzyl.serve.vo.DeviceFunctionDataVo;
import com.zzyl.serve.vo.DeviceReportDataVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.serve.service.IDeviceService;

/**
 * 设备Controller-小程序
 * 
 * @author NicelYHHello
 * @date 2025-08-27
 */
@Api(tags = "设备数据")
@RestController
@RequestMapping("/member/user")
public class DeviceDataMemberController extends BaseController
{
    @Autowired
    private IDeviceService deviceService;

    /**
     * 根据随身设备ID获取健康数据-小程序
     */
    @ApiOperation("获取健康数据")
    @GetMapping("/queryServiceProperties/{iotId}")
    public R<List<DeviceReportDataVo>> getInfo(@ApiParam("设备ID") @PathVariable("iotId") String iotId)
    {
        return R.ok(deviceService.getByIdDeviceData(iotId));
    }

    /**
     * 按天统计查询指标数据-小程序
     */
    @ApiOperation("按天统计查询指标数据")
    @GetMapping("/queryDeviceDataListByDay")
    public R<List<DeviceFunctionDataVo>> queryDeviceDataListByDay(QueryDeviceDataDto dto){
        return R.ok(deviceService.queryDeviceDataListByDay(dto));
    }

    /**
     * 按周统计查询指标数据-小程序
     */
    @ApiOperation("按周统计查询指标数据")
    @GetMapping("/queryDeviceDataListByWeek")
    public R<List<DeviceFunctionDataVo>> queryDeviceDataListByWeek(QueryDeviceDataDto dto){
        return R.ok(deviceService.queryDeviceDataListByWeek(dto));
    }
}
